
<html><HEAD>
<LINK REL=STYLESHEET HREF="default.css" TYPE="text/css">
<TITLE>
Using the Database painter</TITLE>
</HEAD>
<BODY>

<!-- Header -->
<p class="ancestor" align="right"><A HREF="pbugp139.htm">Previous</A>&nbsp;&nbsp;<A HREF="pbugp141.htm" >Next</A>
<!-- End Header -->
<A NAME="CCJDEBJA"></A><h1>Using the Database painter</h1>
<A NAME="TI4116"></A><p>To open the Database painter, click the Database button in the PowerBar.</p>
<A NAME="BDCJDGDC"></A><h4>About the painter</h4>
<A NAME="TI4117"></A><p>Like the other PowerBuilder painters, the Database painter contains
a menu bar, customizable PainterBars, and several views. All database-related
tasks that you can do in PowerBuilder can be done in the Database painter.</p>
<br><img src="images/dbpt.gif">
<A NAME="BDCDGAID"></A><h4>Views in the Database painter</h4>
<A NAME="TI4118"></A><p><A HREF="pbugp140.htm#BDCGFBID">Table 16-1</A> lists
the views available in the Database painter.</p>
<A NAME="BDCGFBID"></A><table cellspacing=0 cellpadding=6 border=1 frame="void" rules="all"><caption>Table 16-1: Database painter views</caption>
<tr><th  rowspan="1"  ><A NAME="TI4119"></A>View</th>
<th  rowspan="1"  ><A NAME="TI4120"></A>Description</th>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4121"></A>Activity Log</td>
<td  rowspan="1"  ><A NAME="TI4122"></A>Displays the <ACRONYM title = "sequel" >SQL</ACRONYM> syntax
generated by the actions you execute.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4123"></A>Columns</td>
<td  rowspan="1"  ><A NAME="TI4124"></A>Used to create and/or modify
a table's columns.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4125"></A>Extended Attributes </td>
<td  rowspan="1"  ><A NAME="TI4126"></A>Lists the display formats, edit styles,
and validation rules defined for the selected database connection. </td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4127"></A>Interactive <ACRONYM title = "sequel" >SQL</ACRONYM></td>
<td  rowspan="1"  ><A NAME="TI4128"></A>Used to build, execute, or explain <ACRONYM title = "sequel" >SQL</ACRONYM>. </td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4129"></A>Object Details</td>
<td  rowspan="1"  ><A NAME="TI4130"></A>Displays an object's properties.
For some objects, its properties are read-only; for others, properties
can be modified.This view is analogous to the Properties view in other
painters.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4131"></A>Object Layout</td>
<td  rowspan="1"  ><A NAME="TI4132"></A>Displays a graphical representation of
tables and their relationships. </td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4133"></A>Objects</td>
<td  rowspan="1"  ><A NAME="TI4134"></A>Lists database interfaces and profiles. For
an active database connection, might also list all or some of the
following objects associated with that database: groups, metadata types,
procedures and functions, tables, columns, primary and foreign keys,
indexes, users, views, driver information, events, triggers, and
utilities (the database components listed depend on the database
and your user privileges).</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4135"></A>Results</td>
<td  rowspan="1"  ><A NAME="TI4136"></A>Displays data in a grid, table, or freeform
format.</td>
</tr>
</table>
<A NAME="BDCFGJCD"></A><h4>Dragging and dropping</h4>
<A NAME="TI4137"></A><p>You can select certain database objects from the Objects view
and drag them to the Object Details, Object Layout, Columns, and/or <ACRONYM title = "I sequel" >ISQL</ACRONYM> views. Position the pointer
on the database object's icon and drag it to the appropriate
view. </p>
<A NAME="TI4138"></A><table cellspacing=0 cellpadding=6 border=1 frame="void" rules="all"><caption>Table 16-2: Using drag and drop in the Database painter</caption>
<tr><th  rowspan="1"  ><A NAME="TI4139"></A>Object</th>
<th  rowspan="1"  ><A NAME="TI4140"></A>Can be dragged to</th>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4141"></A>Driver, group, metadata type, procedure
or function, table, column, user, primary or foreign key, index,
event trigger</td>
<td  rowspan="1"  ><A NAME="TI4142"></A>Object Details view</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4143"></A>Table or view</td>
<td  rowspan="1"  ><A NAME="TI4144"></A>Object Layout view</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4145"></A>Table or column</td>
<td  rowspan="1"  ><A NAME="TI4146"></A>Columns view </td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4147"></A>Procedure or view </td>
<td  rowspan="1"  ><A NAME="TI4148"></A><ACRONYM title = "I sequel" >ISQL</ACRONYM> view </td>
</tr>
</table>
<A NAME="BDCBGECG"></A><h4>Database painter tasks</h4>
<A NAME="TI4149"></A><p><A HREF="pbugp140.htm#BDCIFIEE">Table 16-3</A> describes
how to do some basic tasks in the Database painter. Most of these tasks
begin in the Objects view. Many can be accomplished by dragging
and dropping objects into different views. If you prefer, you can
use buttons or menu selections from the menu bar or from pop-up
menus. </p>
<A NAME="BDCIFIEE"></A><table cellspacing=0 cellpadding=6 border=1 frame="void" rules="all"><caption>Table 16-3: Common tasks in the Database painter</caption>
<tr><th  rowspan="1"  ><A NAME="TI4150"></A>To</th>
<th  rowspan="1"  ><A NAME="TI4151"></A>Do this</th>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4152"></A>Modify a database profile</td>
<td  rowspan="1"  ><A NAME="TI4153"></A>Highlight a database profile and select
Properties from the Object or pop-up menu or use the Properties
button.<A NAME="TI4154"></A><p>You can use the Import and Export Profiles menu selections
to copy profiles. For more information, see the section on importing
and exporting database profiles in <i>Connecting to Your
Database</i>
. </p></td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4155"></A>Connect to a database</td>
<td  rowspan="1"  ><A NAME="TI4156"></A>Highlight a database profile and then
select Connect from the File or pop-up menu or use the Connect button. With
File&gt;Recent Connections, you can review and return to earlier
connections. You can also make database connections using the Database
Profile button.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4157"></A>Create new profiles, tables, views, columns, keys,
indexes, or groups</td>
<td  rowspan="1"  ><A NAME="TI4158"></A>Highlight the database object and select
New from the Object or pop-up menu or use the Create button.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4159"></A>Modify database objects</td>
<td  rowspan="1"  ><A NAME="TI4160"></A>Drag the object to the Object Details
view.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4161"></A>Graphically display tables </td>
<td  rowspan="1"  ><A NAME="TI4162"></A>Drag the table icon from the list in
the Objects view to the Object Layout view, or highlight the table
and select Add To Layout from the Object or pop-up menu.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4163"></A>Manipulate data </td>
<td  rowspan="1"  ><A NAME="TI4164"></A>Highlight the table and select Grid,
Tabular, or Freeform from the Object&gt;Data menu or the pop-up
menu Edit Data item, or use the appropriate Data Manipulation button.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4165"></A>Build, execute or explain <ACRONYM title = "sequel" >SQL</ACRONYM></td>
<td  rowspan="1"  ><A NAME="TI4166"></A>Use the <ACRONYM title = "I sequel" >ISQL</ACRONYM> view
to build <ACRONYM title = "sequel" >SQL</ACRONYM> statements. Use
the Paste <ACRONYM title = "sequel" >SQL</ACRONYM> button to paste <b>SELECT</b>, <b>INSERT</b>, <b>UPDATE</b>, and <b>DELETE</b> statements
or type them directly into the view's workspace. To execute or
explain <ACRONYM title = "sequel" >SQL</ACRONYM>, select Execute <ACRONYM title = "sequel" >SQL</ACRONYM> and Explain <ACRONYM title = "sequel" >SQL</ACRONYM> from
the Design or pop-up menu. </td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4167"></A>Define or modify extended attributes</td>
<td  rowspan="1"  ><A NAME="TI4168"></A>Select from the Object&gt;Insert
menu the type of extended attribute you want to define or modify,
or highlight the extended attribute from the list in the Extended Attributes
view and select New or Properties from the pop-up menu.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4169"></A>Specify extended attributes for a column</td>
<td  rowspan="1"  ><A NAME="TI4170"></A>Drag the column to the Object Details
view and select the Extended Attributes tab.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4171"></A>Access database utilities</td>
<td  rowspan="1"  ><A NAME="TI4172"></A>Double-click a utility in the Objects
view to launch it.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4173"></A>Log your work</td>
<td  rowspan="1"  ><A NAME="TI4174"></A>Select Design&gt;Start Log from
the menu bar. To see the <ACRONYM title = "sequel" >SQL</ACRONYM> syntax
generated, display the Activity Log view.</td>
</tr>
</table>
<A NAME="BABDFCJG"></A><h2>Modifying database preferences</h2>
<A NAME="TI4175"></A><p>To modify database preferences, select Design&gt;Options
from the menu bar. Some preferences are specific to the database
connection; others are specific to the Database painter.</p>
<A NAME="BDCEDIJD"></A><h4>Preferences on the General
property page</h4>
<A NAME="TI4176"></A><p>The Connect To Default Profile, Shared Database Profiles,
Keep Connection Open, Use Extended Attributes, and Read Only preferences
are specific to the database connection. </p>
<A NAME="TI4177"></A><p>The remaining preferences are specific to the Database painter.
For information about modifying these preferences, see <i>Connecting
to Your Database</i>
.</p>
<A NAME="TI4178"></A><table cellspacing=0 cellpadding=6 border=1 frame="void" rules="all"><caption>Table 16-4: Database painter preferences</caption>
<tr><th  rowspan="1"  ><A NAME="TI4179"></A>Database preference</th>
<th  rowspan="1"  ><A NAME="TI4180"></A>What PowerBuilder does
with the specified preference</th>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4181"></A>Columns in the Table List</td>
<td  rowspan="1"  ><A NAME="TI4182"></A>When PowerBuilder displays tables graphically,
eight table columns display unless you change the number of columns.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4183"></A><ACRONYM title = "sequel" >SQL</ACRONYM> Terminator Character</td>
<td  rowspan="1"  ><A NAME="TI4184"></A>PowerBuilder uses the semicolon as the <ACRONYM title = "sequel" >SQL</ACRONYM> statement terminator unless you
enter a different terminator character in the box. Make sure that
the character you choose is not reserved for another use by your
database vendor. For example, using the slash character (/)
causes compilation errors with some DBMSs.</td>
</tr>
<tr><td  rowspan="1"  ><A NAME="TI4185"></A>Refresh Table List</td>
<td  rowspan="1"  ><A NAME="TI4186"></A>When PowerBuilder first displays a table
list, PowerBuilder retrieves the table list from the database and
displays it. To save time, PowerBuilder saves this list internally
for reuse to avoid regeneration of very large table lists. The table
list is refreshed every 30 minutes (1800 seconds) unless you specify
a different refresh rate.</td>
</tr>
</table>
<A NAME="BDCDJJGH"></A><h4>Preferences on the Object
Colors property page</h4>
<A NAME="TI4187"></A><p>You can set colors separately for each component of the Database painter's graphical
table representation: the table header, columns, indexes, primary
key, foreign keys, and joins. Set a color preference by selecting
a color from a drop-down list.</p>
<A NAME="TI4188"></A><p>You can design custom colors that you can use when you select
color preferences. To design custom colors, select Design&gt;Custom
Colors from the menu bar and work in the Custom Colors dialog box.</p>
<A NAME="BABGECDE"></A><h2>Logging your work</h2>
<A NAME="TI4189"></A><p>As you work with your database, you generate <ACRONYM title = "sequel" >SQL</ACRONYM> statements. As you define a new
table, for example, PowerBuilder builds a <b>SQL CREATE TABLE</b> statement
internally. When you save the table, PowerBuilder sends the <ACRONYM title = "sequel" >SQL</ACRONYM> statement to the DBMS to create
the table. Similarly, when you add an index, PowerBuilder builds a <b>CREATE
INDEX</b> statement.</p>
<A NAME="TI4190"></A><p>You can see all <ACRONYM title = "sequel" >SQL</ACRONYM> generated
in a Database painter session in the Activity Log view. You can also save
this information to a file. This allows you to have a record of
your work and makes it easy to duplicate the work if you need to create
the same or similar tables in another database.</p>
<A NAME="TI4191"></A><p><img src="images/proc.gif" width=17 height=17 border=0 align="bottom" alt="Steps"> To start logging your work:</p>
<ol><li class=fi><p>Open the Database painter.</p></li>
<li class=ds><p>Select Start Log from the Design menu or the pop-up
menu in the Activity Log view.</p><p>PowerBuilder begins sending all generated syntax to the Activity
Log view.</p></li></ol>
<br><A NAME="TI4192"></A><p><img src="images/proc.gif" width=17 height=17 border=0 align="bottom" alt="Steps"> To stop the log:</p>
<ol><li class=fi><p>Select Stop Log from the Design menu or the
pop-up menu in the Activity Log view.</p><p>PowerBuilder stops sending the generated syntax to the Activity
Log view. Your work is no longer logged. </p></li></ol>
<br><A NAME="TI4193"></A><p><img src="images/proc.gif" width=17 height=17 border=0 align="bottom" alt="Steps"> To save the log to a permanent text file:</p>
<ol><li class=fi><p>Select Save or Save As from the File menu.</p></li>
<li class=ds><p>Name the file and click Save. The default file
extension is <i>SQL</i>, but you can change that if
you want to. </p></li></ol>
<br><p><img src="images/note.gif" width=17 height=17 border=0 align="bottom" alt="Note"> <span class=shaded>Submitting the log to your DBMS</span> <A NAME="TI4194"></A>You can open a saved log file and submit it to your DBMS in
the <ACRONYM title = "I sequel" >ISQL</ACRONYM> view. For more information,
see <A HREF="pbugp147.htm#CCJCFJIF">"Building and executing <ACRONYM title = "sequel" >SQL</ACRONYM> statements"</A>.</p>

